import { defineStore } from "pinia";
import { ref } from "vue";
import useModStore from "./mod.store";
const key = "app";

const useAppStore = defineStore(key, () => {
  const { initMod } = useModStore();

  const appList = ref<AppDto[]>([]);

  const initApp = async () => {
    appList.value = defaultApp;
    const modList = await initMod();
    console.log("Show mod", modList);
    appList.value = appList.value.concat(modList);
  };

  return {
    appList,
    initApp,
  };
});

export class AppDto {
  id?: number;
  name: string = "";
  code: string = "";
  icon: string = "";
  isSys: boolean = false;
  constructor(id: number, name: string, code: string, icon: string) {
    (this.id = id), (this.name = name), (this.code = code), (this.icon = icon);
  }
}

const defaultApp: AppDto[] = [
  {
    id: 0,
    name: "设置",
    code: "setting",
    icon: "#",
    isSys: true,
  },
  {
    id: 1,
    name: "快速打开",
    code: "quickly",
    icon: "#",
    isSys: true,
  },
];

export default useAppStore;
